﻿using mscook.core.domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate.Linq;

namespace mscook.core.repositories
{
    public class MaterialRepository : Repository<Material>,IMaterialRepository
    {
        public IList<Material> GetByKeyword(string keyword, int start, int limit, out long total)
        {
            var query = (from x in this.Session.Query<Material>() select x)
             .Where(o => o.IsDelete == false
                 && (o.Name.Contains(keyword) || o.Summary.Contains(keyword))).OrderByDescending(o => o.CreateTime);
            total = query.Count();
            return query.Skip(start).Take(limit).ToList();
        }
    }
}
